package com.lanchewuyou.user.driver.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lanchewuyou.user.driver.R;
import com.lanchewuyou.user.driver.bean.OrderYesItem;

import java.util.ArrayList;
import java.util.List;

/**
 * 易理赔已完成订单列表适配器
 */
public class OrderYesAdapter extends BaseAdapter {

    private List<OrderYesItem> orderYesItemList = new ArrayList<>();
    private LayoutInflater inflater;

    public OrderYesAdapter(List<OrderYesItem> orderYesItemList, Context mContext) {
        this.orderYesItemList = orderYesItemList;
        inflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return orderYesItemList.size();
    }

    @Override
    public Object getItem(int position) {
        return orderYesItemList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        OrderYesItem orderYesItem = orderYesItemList.get(position);
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = inflater.inflate(R.layout.order_yes_item, null);
            viewHolder.orderYesCaseType = (TextView) convertView.findViewById(R.id.order_yes_case_type);
            viewHolder.orderYesCaseTime = (TextView) convertView.findViewById(R.id.order_yes_case_time);
            viewHolder.orderYesCaseAdd = (TextView) convertView.findViewById(R.id.order_yes_case_add);
            viewHolder.orderYesPayType = (TextView) convertView.findViewById(R.id.order_yes_pay_type);
            viewHolder.orderYesPhoto = (TextView) convertView.findViewById(R.id.order_yes_case_photo);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.orderYesCaseType.setText(orderYesItem.getType());
        viewHolder.orderYesCaseTime.setText(orderYesItem.getTime());
        viewHolder.orderYesCaseAdd.setText(orderYesItem.getAddress());
        viewHolder.orderYesPayType.setText(orderYesItem.getPayType());
        viewHolder.orderYesPhoto.setText(orderYesItem.getPhoto() + "");

        return convertView;
    }

    class ViewHolder {
        public TextView orderYesCaseType;
        public TextView orderYesCaseTime;
        public TextView orderYesCaseAdd;
        public TextView orderYesPayType;
        public TextView orderYesPhoto;
    }
}
